<template>
  <fragment>
    <TelRecord ref="telRcrd" dep="shop" :call-tel="callTel" :call-id="callid" :record-id="recordId"></TelRecord>
    <!-- B2C电商订单记录-->
    <!-- <OrderRecord ref="orderRcrd" online :call-tel="callTel" :call-id="callid" :record-id="recordId" @relevance="relevanceHandle"></OrderRecord> -->
    <!-- ECO电商订单记录-->
    <!-- <OrderRecord ref="orderRcrdECO" online eco :call-tel="callTel" :call-id="callid" :record-id="recordId" @relevance="relevanceHandle"></OrderRecord> -->
    <!-- <OrderRecord ref="orderReatilRcrd" :call-tel="callTel" :call-id="callid" :record-id="recordId" @relevance="relevanceHandle"></OrderRecord> -->
    <ShopCallReg :order-data="orderData" v-bind="$props" @refresh="$emit('refresh', 'save')"></ShopCallReg>
  </fragment>
</template>
<script>
import TelRecord from './TelRecord'
// import OrderRecord from './OrderRecord'
import ShopCallReg from './ShopCallReg'
import { deepCopy } from '@/utils'
import { getOrderDetailPCode } from '@/api/mscInfo'

export default {
  name: 'DisplayClient',
  components: {
    TelRecord,
    // OrderRecord,
    ShopCallReg
  },
  props: {
    callTel: {
      type: String,
      default: ''
    },
    callid: {
      type: String,
      default: ''
    },
    recordId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      orderData: {}
    }
  },
  methods: {
    async relevanceHandle(row, online, eco) {
      const d = deepCopy(row)

      if (!online) {
        delete d.storeName
        row.online = online
        row.eco = eco
        this.$set(this, 'orderData', row)

        if (this.$refs.orderRcrd) this.$refs.orderRcrd.clearRelevance()
        if (this.$refs.orderRcrdECO) this.$refs.orderRcrdECO.clearRelevance()
      } else {
        await getOrderDetailPCode({ pcode: d.pcode }).then((res) => {
          if (res.success === 1) {
            const orderData = res.data
            this.$set(this, 'orderData', orderData)
          }
        })
        if (eco) this.$refs.orderRcrd.clearRelevance()
        else this.$refs.orderRcrdECO.clearRelevance()

        this.$refs.orderReatilRcrd.clearRelevance()
      }
      // this.orderData = d
    }
  }
}
</script>

